package com.fbinggun.dt;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.sql.SQLException;

public class TaskCommand implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if(args!=null&&args.length==0){
            try {
                DailyTask.choiceGui.openInventory((Player) sender);
            } catch (SQLException e) {
                throw new RuntimeException(e);
            } catch (ClassNotFoundException e) {
                throw new RuntimeException(e);
            }
            return false;
        }
        if(args[0].equalsIgnoreCase("reload")){
            if(sender.isOp()) {
                try {
                    DailyTask.plugin.unload();
                } catch (SQLException e) {
                    throw new RuntimeException(e);
                } catch (ClassNotFoundException e) {
                    throw new RuntimeException(e);
                }
                DailyTask.plugin.reload();
                sender.sendMessage("重载成功");
            }
            return false;
        }
        return false;
    }
}
